import re

with open('aa.txt','r',encoding='utf-8')as f:
    html = f.read()
with open('bb.txt','r',encoding='utf-8')as f:
    html1 = f.read()
with open('cc.txt','r',encoding='utf-8')as f:
    comm = f.read()

#好评率
pattern_command_rate = r'"goodRateShow":(\d+)'
command_rate = re.compile(pattern_command_rate).findall(comm)[0]+"%"
print(command_rate)
#评价标签
pattern_sign = r'"id":".*?","name":"(.*?)"'
sign = ' '.join(re.compile(pattern_sign).findall(comm))
print(sign)
#评论数
pattern_num = r'"commentCount":(\d+)'
num=re.compile(pattern_num).findall(comm)[0]
print(num)


# pattern_goodsName = r'<div class="fn_text_wrap" id="itemName">(.*?)</div>'
# goodsName = re.compile(pattern_goodsName).findall(html)[0] #商品名
# print(goodsName)
# pattern_price = r'<em>(\d+)</em>.(\d*)'
# a,b = re.compile(pattern_price).findall(html)[0]
# price = a+'.'+b  #获取价格
# print(price)
# pattern_Select = r'{"dim":\d+,".*?"skuId":"\d+"}'
# goodsSelect = ' '.join(re.compile(pattern_Select).findall(html)) #商品可选配置
# print(goodsSelect)
# pattern_shopName = r'"deliver":"(.*?)"'
# shopName = re.compile(pattern_shopName).findall(html)[0]  # 店铺名
# print(shopName)
# pattern_ziying = r'''<em class="u-jd">[^❤]+</em>'''
# if len(re.compile(pattern_ziying).findall(html1))>0:
#     ziying = '是'
# else:
#     ziying = '否'  #是否自营
# print(ziying)
# pattern_goodsBrand  = r"<li title='(.*?)'>品牌"
# goodsBrand = re.compile(pattern_goodsBrand).findall(html1)[0]  #获取品牌
# print(goodsBrand)
# pattern_goodsBelong = r"<li title='.*?'>商品名称：(.*?)</li>"
# goodsBelong = re.compile(pattern_goodsBelong).findall(html1)[0]  #商品署名
# print(goodsBelong)
# pattern_weigth  = r"<li title='.*?'>商品毛重：(.*?)</li>"
# weigth = re.compile(pattern_weigth).findall(html1)[0] #商品重量
# print(weigth)
# pattern_age = r'<dt>上市年份</dt><dd>(.*?)</dd>'
# pattern_age1 = r'<dt>上市月份</dt><dd>(.*?)</dd>'
# age = re.compile(pattern_age).findall(html1)[0]+re.compile(pattern_age1).findall(html1)[0]
# print(age)
# pattern_shopID = '"id":(\d+)'
# shopID  =re.compile(pattern_shopID).findall(html)[0]
# print(shopID)
# shopLink = 'https://shop.m.jd.com/?shopId='+shopID  #店铺链接
# print(shopLink)
# pattern_makein = r"<li title='.*?'>商品产地：(.*?)</li>"
# makein = re.compile(pattern_makein).findall(html1)[0]  #产地
# print(makein)